#include <iostream>
using namespace std;
int y,m,d;


void output();

int main()
{
	while(cin>>y>>m>>d){
		output();
	}
}

void output()
{
	int day=0;
	for(int i=1;i<m;i++){
		if(i==1||i==3||i==5||i==7||i==8||i==10||i==12){
			day=day+31;
		}
		else if(i==2){
			if(y%400==0||(y%4==0&&y%100!=0)){
				day=day+29;
			}
			else day=day+28;
		}
		else day=day+30;
	}
	day=day+d;
	cout<<day<<endl;
}
